std::unordered_map::operator[]
From Cppreference
< cpp | container | unordered map
| T& operator[]( const Key& key );
| (1) | (C++0x feature) |
| T& operator[]( Key&& key );
| (2) | (C++0x feature) |
Inserts a new element to the container using key as the key and default constructed mapped value and returns a reference to the newly constructed mapped value. If an element with key key already exists, no insertion is performed and a reference to its mapped value is returned.
1) Essentially performs (insert(std::make_pair(key, T())).first)->second.
2) Essentially performs (insert(std::make_pair(std::move(key), T())).first)->second.
Contents |
Parameters
| key | - | the key of the element to find |
Return value
reference to the mapped value of the new element if no element with key key existed. Otherwise a reference to the mapped value of the existing element is returned.
Complexity
| This section is incomplete |
See also
| access specified element with bounds checking (public member function) | |